using System;
using System.Collections.Generic;

using GymManager.Exception;
using GymManager.Persistence.DAO;
using GymManager.Persistence.VO;

using log4net;

namespace GymManager.Business
{
    /// <summary>
    /// Class responsible by providing services regarding version history
    /// </summary>
    public class VersionHistoryServices
    {
        // logger instance
        private ILog _logManager = LogManager.GetLogger(typeof(VersionHistoryServices));

        /// <summary>
        /// Method responsible by returning all versions history 
        /// </summary>
        /// <returns>IList - List of All Version History</returns>
        /// <see cref="GymManager.Exception.BusinessException"/>
        public IList<VersionHistory> findAll()
        {
            if (_logManager.IsInfoEnabled)
            {
                _logManager.Info("Begin Method");
            }

            // list to be returned
            IList<VersionHistory> versionHistoryList = null;

            try
            {
                VersionHistoryDAO versionHistoryDAO = new VersionHistoryDAO();
                versionHistoryList = versionHistoryDAO.findAll();
            }
            catch (PersistenceException)
            {
                throw new BusinessException();
            }

            if (_logManager.IsInfoEnabled)
            {
                _logManager.Info("End Method");
            }

            return versionHistoryList;
        }
    }
}
